<template>
  <view class="recharge-container">
    <!-- 余额展示 -->
    <view class="balance-section">
      <text class="balance-label">当前余额</text>
      <text class="balance-amount">￥{{ formatBalance }}</text>
    </view>

    <!-- 充值金额选择 -->
    <view class="amount-section">
      <text class="section-title"> 充值金额</text>
      <view class="amount-grid">
        <view 
          v-for="amount in rechargeAmounts" 
          :key="amount"
          class="amount-item disabled"
        >
          <text class="amount-value">￥{{ amount }}</text>
        </view>
      </view>
    </view>

    <!-- 提示信息 -->
    <view class="notice-section">
      <view class="notice-title">
        <text class="bi bi-exclamation-circle"></text>
        <text>充值须知</text>
      </view>
      <view >
        <text class="notice-text">为防止不法交易、洗钱等违法行为，本平台关闭在线充值，仅开放线下门店充值服务。</text>
        <view class="uni-error ">
          <text class="bi bi-shop "></text>
          <text class="uni-mx-4">请前往墨枢线下门店或联系管理员进行充值</text>
        </view>
      </view>
    </view>

    <!-- 充值按钮 -->
    <button class="recharge-btn" disabled>
   <text class="bi bi-wechat"></text>   线上充值暂不可用
    </button>
  </view>
</template>

<script setup>
import { computed } from 'vue';
import { useUserStore } from '@/stores/userStore';

const userStore = useUserStore();

// 充值金额选项
const rechargeAmounts = [100, 200, 500, 1000, 2000, 5000];

// 格式化余额显示
const formatBalance = computed(() => {
  const balance = userStore.userInfo?.balance || 0;
  // 确保balance是数字并保留两位小数
  const formattedNumber = Number(balance).toFixed(2);
  // 添加千位分隔符
  return formattedNumber.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
});
</script>

<style scoped>
.recharge-container {
  padding: 30rpx;
  min-height: 100vh;
  background-color: #f5f5f5;
}

.balance-section {
  background: linear-gradient(135deg, #141E30 0%, #243B55 100%);
  padding: 40rpx;
  border-radius: 20rpx;
  color: #fff;
  text-align: center;
  margin-bottom: 30rpx;
  box-shadow: 0 4rpx 12rpx rgba(0,0,0,0.1);
}

.balance-label {
  font-size: 28rpx;
  opacity: 0.9;
  margin-bottom: 10rpx;
  display: block;
}

.balance-amount {
  font-size: 60rpx;
  font-weight: bold;
  color: #FFD700;
  text-shadow: 0 2rpx 4rpx rgba(0,0,0,0.3);
}

.amount-section {
  background: #fff;
  padding: 30rpx;
  border-radius: 20rpx;
  margin-bottom: 30rpx;
}

.amount-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20rpx;
}

.amount-item {
  background: #f8f8f8;
  padding: 30rpx 20rpx;
  border-radius: 10rpx;
  text-align: center;
  border: 2rpx solid #eee;
}

.amount-item.disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.amount-value {
  font-size: 32rpx;
  color: #666;
}

.notice-section {
  background: #fff;
  padding: 30rpx;
  border-radius: 20rpx;
  margin-bottom: 30rpx;
}

.notice-title {
  display: flex;
  align-items: center;
  gap: 10rpx;
  color: #ff9800;
  margin-bottom: 20rpx;
}

.notice-content {
  font-size: 28rpx;
  color: #666;
  line-height: 1.6;
}

.notice-text {
  display: block;
  margin-bottom: 20rpx;
}

.store-info {
  display: flex;
  align-items: center;
  gap: 10rpx;
  color: #2196f3;
}

.recharge-btn {
  background: #ccc;
  color: #666;
  padding: 25rpx;
  border-radius: 10rpx;
  text-align: center;
  margin-top: 40rpx;
  font-size: 32rpx;
}

.recharge-btn[disabled] {
  background: #eee;
  color: #999;
}
</style>